export default function request(functionName, data = {}) {
  return new Promise((resolve, reject) => {
    // 获取列表
    if (functionName === 'list') {
      const cacheList = localStorage.getItem('list')
      if (cacheList) {
        resolve(JSON.parse(cacheList))
      } else {
        const initList = [{
          nameId: 0,
          name: '张三',
          openId: 'sfsfssdgfdga',
          docId: '00',
          docName: 'Web前端性能优化',
          docUrl: 'https://editor.csdn.net/md/?articleId=106026276',
          score: 90
        }]
        localStorage.setItem('list', JSON.stringify(initList))
        resolve(initList)
      }
    }
    // 编辑
    if (functionName === 'edit') {
      localStorage.setItem('list', data.list)
      resolve()
    }

    reject(new Error('请求错误！'))
  })
}
